<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

const goBack = () => {
  if (window.history.length > 1) {
    router.back()
  } else {
    router.push('/')
  }
}
</script>

<template>
  <div class="apple-screen">
    <div class="aurora-bg">
      <div class="glow glow-1"></div>
      <div class="glow glow-2"></div>
      <div class="glow glow-3"></div>
    </div>

    <main class="glass-card">
      <div class="content-container">
        <!-- 404 数字 -->
        <div class="error-number">
          <span class="number-4">4</span>
          <span class="number-0">0</span>
          <span class="number-4-2">4</span>
        </div>

        <!-- 错误信息 -->
        <div class="error-content">
          <h1 class="error-title">页面未找到</h1>
          <p class="error-description">抱歉，您访问的页面不存在或已被移动</p>
        </div>

        <!-- 装饰图标 -->
        <div class="icon-container">
          <svg
            class="error-icon"
            viewBox="0 0 100 100"
            fill="none"
            xmlns="http://www.w3.org/2000/svg"
          >
            <circle
              cx="50"
              cy="50"
              r="40"
              stroke="currentColor"
              stroke-width="2"
              stroke-opacity="0.2"
            />
            <path
              d="M35 35L65 65M65 35L35 65"
              stroke="currentColor"
              stroke-width="3"
              stroke-linecap="round"
              stroke-opacity="0.3"
            />
          </svg>
        </div>

        <!-- 返回按钮 -->
        <button @click="goBack" class="primary-btn">
          <span class="btn-content">
            <span class="btn-text">返回上一页…</span>
            <svg
              class="arrow-icon"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2.5"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <line x1="5" y1="12" x2="19" y2="12"></line>
              <polyline points="12 5 19 12 12 19"></polyline>
            </svg>
          </span>
        </button>
      </div>

      <div class="shimmer"></div>
    </main>
  </div>
</template>

<style scoped>
/* ----------------------------------
   Design Tokens: macOS Titanium
   ---------------------------------- */
:root {
  --primary-blue: #0071e3;
  --primary-blue-hover: #0077ed;
  --text-main: #1d1d1f;
  --text-sub: #86868b;
  --card-radius: 32px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 沉浸式屏幕 */
.apple-screen {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  overflow: hidden;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', Helvetica, Arial, sans-serif;
}

/* 背景光效 */
.aurora-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  opacity: 0.8;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: float 15s infinite ease-in-out alternate;
}

.glow-1 {
  top: -10%;
  left: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, #ffe0e0 0%, rgba(255, 255, 255, 0) 70%);
}

.glow-2 {
  bottom: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #f4f0ff 0%, rgba(255, 255, 255, 0) 70%);
  animation-delay: -5s;
}

.glow-3 {
  top: 40%;
  left: 40%;
  width: 30vw;
  height: 30vw;
  background: #fbfbfd;
  animation-delay: -10s;
}

@keyframes float {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(20px, 40px);
  }
}

/* 磨砂卡片 */
.glass-card {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90%;
  max-width: 600px;
  min-height: 500px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(50px) saturate(150%);
  -webkit-backdrop-filter: blur(50px) saturate(150%);
  border-radius: var(--card-radius);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    0 20px 40px -10px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  overflow: hidden;
  padding: 60px 40px;
}

.content-container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

/* 404 数字样式 */
.error-number {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 30px;
  font-weight: 700;
  line-height: 1;
}

.number-4,
.number-0,
.number-4-2 {
  font-size: 8rem;
  background: linear-gradient(135deg, #1d1d1f 0%, #86868b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -4px;
  animation: fadeInUp 0.6s ease-out;
}

.number-0 {
  animation-delay: 0.1s;
  opacity: 0;
  animation-fill-mode: forwards;
}

.number-4-2 {
  animation-delay: 0.2s;
  opacity: 0;
  animation-fill-mode: forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 错误内容 */
.error-content {
  margin-bottom: 40px;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

.error-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.error-description {
  font-size: 1rem;
  color: var(--text-sub);
  font-weight: 400;
  line-height: 1.6;
}

/* 图标容器 */
.icon-container {
  margin-bottom: 40px;
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

.error-icon {
  width: 80px;
  height: 80px;
  color: var(--text-sub);
  opacity: 0.3;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.05);
  }
}

/* 主按钮 */
.primary-btn {
  width: 100%;
  max-width: 280px;
  height: 52px;
  background: var(--primary-blue);
  color: white;
  border: none;
  border-radius: 99px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.2);
  animation: fadeInUp 0.8s ease-out 0.5s both;
  padding: 0;
}

.primary-btn:hover {
  background: var(--primary-blue-hover);
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 113, 227, 0.3);
}

.primary-btn:active {
  transform: scale(0.96);
}

.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn-text {
  display:flex;
  color: black;
  align-items: center;
  justify-content: center;
}

.arrow-icon {
  width: 18px;
  height: 18px;
  color: white;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.primary-btn:hover .arrow-icon {
  transform: translateX(3px);
}

/* 装饰光效 */
.shimmer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 60%
  );
  pointer-events: none;
}

/* 响应式 */
@media (max-width: 768px) {
  .glass-card {
    width: 95%;
    padding: 40px 30px;
    min-height: 400px;
  }

  .number-4,
  .number-0,
  .number-4-2 {
    font-size: 5rem;
  }

  .error-title {
    font-size: 1.5rem;
  }

  .error-description {
    font-size: 0.9rem;
  }

  .error-icon {
    width: 60px;
    height: 60px;
  }

  .primary-btn {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .number-4,
  .number-0,
  .number-4-2 {
    font-size: 4rem;
    gap: 4px;
  }

  .error-title {
    font-size: 1.25rem;
  }
}
</style>
